<?php 
namespace Home\Widget;
use Think\Controller;
/**
* ==============================================
*  http://www.liuhuanhui.cn
* ==============================================
* @date: 2014-10-8
* @author:liuhuanhui
* @encoding: UTF-8
*/
class ModuleWidget extends Controller
{
	/**
	 * 选项卡
	 * @param unknown $id
	 * @param unknown $title
	 * @param unknown $count
	 * @param unknown $modulename
	 */
	function Tab($id,$title,$count,$modulename,$page)
	{	
    	$this->controls=D('PageControl')->where('page="'.$page.'" and pid='.$id)->order('number')->select();
		$this->display('Module:TAB');
	}
	/**
	 * 列表
	 * @param unknown $id
	 * @param unknown $title
	 * @param unknown $count
	 * @param unknown $modulename
	 */
	function UL($id,$title,$count,$modulename)
	{	
		$this->UL=array(title=>$title,count=>$count,mname=>$modulename);
		$this->display('Module:UL');
	}
	/**
	 * 最近他说
	 */
	function  newsasy($id,$title,$count,$modulename)
	{
		$this->say=M('says')->order('date desc')->getField('content');
		$this->display('Module:newsay');
	}
	/**
	**音乐
	**/
	function music()
	{
	$this->display('Module:music');
	}

		function serachArticle()
    	{
    	$this->display('Module:serachArticle');
    	}
	/**
	 * 天气
	 */
	function tianqi()
	{
		$this->display('Module:tianqi');
	}
	/**
	 * 头部
	 */
	function header()
	{
		$this->keywords=M('options')->where("name='KEYWORDS'")->getField('value');
		$this->topText=M('options')->where("name='topText'")->getField('value');
		$this->description=M('options')->where("name='DESCRIPTION'")->getField('value');
		$this->menus=ParentChildSort(D('Navs')->where('ishide<>"y"')->order('orders')->relation(TRUE)->select());
		$this->display('Module:header');
	}
	/**
	 * 底部
	 */
	function footer()
	{
		$this->links=M('links')->field('name,href')->where('ishide="n"')->order('orders')->select();
		$this->display('Module:footer');
	}
	
	/**
	 * 置顶推荐
	 */
	function top()
	{    	
		$this->tops=M('blogs')->where('isTop="y" and type="Word"')->field('id,title,content,titleHead,image')->limit(4)->select();
		$this->display('Module:top');
	}
	/**
	 * 显示我的信息
	 */
	function meinfo()
	{	
		$about=M('options')->field('name,value')->where(array(group=>1))->select();
		$data=array();
		foreach ($about as $a)
		$data[$a['name']]=$a['value'];
		//$data['age']=date('Y-m-d')-date('Y-m-d',$data['about_BORNDATE']);
		$this->assign('m',$data);
		$this->display('Module:meinfo');
	}
	/**
	 * 文章分类
	 */
	function blogcate($count)
	{		
		$this->data=M('Sorts')->field('id,name')->select();
		$this->display('Module:cate');
	}
	/**
	 *最新发布
	 */
	function latest($title,$count)
	{	
		$this->title=$title;
		$this->data=D('BlogsView')->field('id,title')->order('date desc')->limit(9)->select();
		$this->display('Module:latest');
	}
	/**
	 * 热评文章
	 */
	function ds_hot($title)
	{
		$this->title=$title;
		$this->display('Module:hot');
	}	
	/**
	 * 多说评论
	 */
	function ds_comment($key,$title,$url)
	{
		$this->iskey=$key;
		$this->title=$title;
		$this->url=$url;
		$this->display('Module:comment');
	}
	/**
	 * 最新评论
	 */
	function ds_newcomments($title)
	{
		$this->title=$title;
		$this->display('Module:newcomments');
	}
	/**
	 * 最新访客
	 */
	function ds_newvisitor($title)
	{
		$this->title=$title;
		$this->display('Module:newvisitor');
	}
	
	/**
	 * 选项卡信息
	 */
	function tabinfo()
	{
		$this->display('Module:tabinfo');
	}

	/**
	 * 文章归档
	 */
	function blogdate($title,$count)
	{
		$this->title=$title;
		$model=M('blogs');
		$this->date=$model->query('SELECT YEAR(FROM_UNIXTIME(DATE)) AS YEAR,MONTH(FROM_UNIXTIME(DATE)) AS MONTH FROM lhh_blogs GROUP BY YEAR(FROM_UNIXTIME(DATE)), MONTH(FROM_UNIXTIME(DATE))');
		$this->display('Module:blogdate');
	}
	/**
	 * 文章归档Select
	 */
	function blogdate2($title)
	{	
		$this->title=$title;
		$model=M('blogs');
		$this->date=$model->query('SELECT YEAR(FROM_UNIXTIME(DATE)) AS YEAR,MONTH(FROM_UNIXTIME(DATE)) AS MONTH FROM lhh_blogs GROUP BY YEAR(FROM_UNIXTIME(DATE)), MONTH(FROM_UNIXTIME(DATE))');
		$this->display('Module:blogdate2');
	}
	/**
	 * 标签
	 */
	function tag($title)
	{
		$this->title=$title;
		$this->display('Module:tag');
	}
	/**
	 * 站点统计
	 */
	function webinfo($title)
	{	
		$ArticleCount=M('blogs')->count();
		$SortCount=M('sorts')->count();
		$LinkCount=M('links')->count();
		$Rundate=M('options')->where(array(name=>'RUNDATE'))->find();
		$LastDate=M('blogs')->field(date)->order('date desc')->find();
		$data=array(
			BlogCount=>$ArticleCount,
			SortCount=>$SortCount,
					LinkCount=>$LinkCount,
					Rundate=>$Rundate['value'],
					LastDate=>$LastDate,
		);
		$this->assign('data',$data);
		$this->title=$title;
		$this->display('Module:webinfo');
	}
	/**
	 * 网页标题
	 */
	function webtitle()
	{
		//$this->webtitle='AAAAAAAAAAAA';
		//M('options')->getField('values');
		//var_dump($this->webtitle);
	}
}
?>